home *** CD-ROM | disk | FTP | other *** search
/ Kellogg's Amérique / Kellogg's Amérique / main.swf / scripts / fl / controls / listClasses / CellRenderer.as next >
Text File  |  2020-08-04  |  3KB  |  113 lines

  1. package fl.controls.listClasses
  2. {
  3.    import fl.controls.LabelButton;
  4.    import flash.events.MouseEvent;
  5.    
  6.    public class CellRenderer extends LabelButton implements ICellRenderer
  7.    {
  8.       
  9.       private static var defaultStyles:Object = {
  10.          "upSkin":"CellRenderer_upSkin",
  11.          "downSkin":"CellRenderer_downSkin",
  12.          "overSkin":"CellRenderer_overSkin",
  13.          "disabledSkin":"CellRenderer_disabledSkin",
  14.          "selectedDisabledSkin":"CellRenderer_selectedDisabledSkin",
  15.          "selectedUpSkin":"CellRenderer_selectedUpSkin",
  16.          "selectedDownSkin":"CellRenderer_selectedDownSkin",
  17.          "selectedOverSkin":"CellRenderer_selectedOverSkin",
  18.          "textFormat":null,
  19.          "disabledTextFormat":null,
  20.          "embedFonts":null,
  21.          "textPadding":5
  22.       };
  23.        
  24.       
  25.       protected var _data:Object;
  26.       
  27.       protected var _listData:ListData;
  28.       
  29.       public function CellRenderer()
  30.       {
  31.          super();
  32.          toggle = true;
  33.          focusEnabled = false;
  34.       }
  35.       
  36.       public static function getStyleDefinition() : Object
  37.       {
  38.          return defaultStyles;
  39.       }
  40.       
  41.       override protected function toggleSelected(param1:MouseEvent) : void
  42.       {
  43.       }
  44.       
  45.       override public function get selected() : Boolean
  46.       {
  47.          return super.selected;
  48.       }
  49.       
  50.       public function set listData(param1:ListData) : void
  51.       {
  52.          _listData = param1;
  53.          label = _listData.label;
  54.          setStyle("icon",_listData.icon);
  55.       }
  56.       
  57.       override public function set selected(param1:Boolean) : void
  58.       {
  59.          super.selected = param1;
  60.       }
  61.       
  62.       public function set data(param1:Object) : void
  63.       {
  64.          _data = param1;
  65.       }
  66.       
  67.       public function get listData() : ListData
  68.       {
  69.          return _listData;
  70.       }
  71.       
  72.       override public function setSize(param1:Number, param2:Number) : void
  73.       {
  74.          super.setSize(param1,param2);
  75.       }
  76.       
  77.       override protected function drawLayout() : void
  78.       {
  79.          var _loc1_:Number = NaN;
  80.          var _loc2_:Number = NaN;
  81.          var _loc3_:Number = NaN;
  82.          _loc1_ = Number(getStyleValue("textPadding"));
  83.          _loc2_ = 0;
  84.          if(icon != null)
  85.          {
  86.             icon.x = _loc1_;
  87.             icon.y = Math.round(height - icon.height >> 1);
  88.             _loc2_ = icon.width + _loc1_;
  89.          }
  90.          if(label.length > 0)
  91.          {
  92.             textField.visible = true;
  93.             _loc3_ = Math.max(0,width - _loc2_ - _loc1_ * 2);
  94.             textField.width = _loc3_;
  95.             textField.height = textField.textHeight + 4;
  96.             textField.x = _loc2_ + _loc1_;
  97.             textField.y = Math.round(height - textField.height >> 1);
  98.          }
  99.          else
  100.          {
  101.             textField.visible = false;
  102.          }
  103.          background.width = width;
  104.          background.height = height;
  105.       }
  106.       
  107.       public function get data() : Object
  108.       {
  109.          return _data;
  110.       }
  111.    }
  112. }
  113.